import { IsString, IsNotEmpty, MaxLength, IsOptional } from "class-validator";
import { ApiProperty, ApiPropertyOptional } from "@nestjs/swagger";
import { QueryDto } from "/@/common/dto/query.dto";

export class AddGoodsDto {
  @ApiProperty({ description: "商品名称" })
  @MaxLength(50, { message: "name长度不超过50" })
  @IsString({ message: "不是有效的name" })
  @IsNotEmpty({ message: "name不能为空" })
  readonly name: string;

  @ApiProperty({ description: "商品重量" })
  readonly weight: number;

  @ApiProperty({ description: "商品分类" })
  readonly type: Array<string>;

  @IsOptional()
  @ApiPropertyOptional({ description: "商品标签" })
  @IsString({ message: "不是有效的label" })
  readonly label: string;

  @ApiProperty({ description: "商品图片" })
  readonly urls: string;

  @IsOptional()
  @ApiPropertyOptional({ description: "商品详情" })
  @IsString({ message: "不是有效的details" })
  readonly details: string;

  @IsOptional()
  @ApiPropertyOptional({ description: "商品状态" })
  @IsString({ message: "status必须为字符串" })
  @IsNotEmpty({ message: "status不能为空" })
  readonly status: string;

  @IsOptional()
  @ApiPropertyOptional({ description: "备注" })
  @IsString()
  readonly des: string;
}

export class DelGoodsDto {}
export class EditGoodsDto {}
export class GetGoodsTypeDto {
  @IsOptional()
  @ApiPropertyOptional({ description: "商品pid" })
  readonly pid: number;
}
export class GetGoodsListDto extends QueryDto {
  @IsOptional()
  @ApiPropertyOptional({ description: "搜索字段" })
  readonly text: string;
}
export class GetGoodsDto extends QueryDto {
  @IsOptional()
  @ApiPropertyOptional({ description: "商品分类id" })
  readonly id: number;
}

export class GetGoodsDetailsDto {
  @ApiProperty({ description: "商品id" })
  readonly id: number;
}
